package com.gxc.controller;

import com.gxc.utils.RestControllerResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author GongXincheng
 * @since 2019-08-08 16:15
 */
@RestController
public class UploadController {

    @PostMapping("/upload")
    public RestControllerResult upload(MultipartFile file) {
        try {
            file.transferTo(new File("/Users/gxc/My_Tmp", file.getOriginalFilename()));
            return RestControllerResult.success(true);
        } catch (IOException e) {
            e.printStackTrace();
            return RestControllerResult.error(e.getMessage());
        }
    }

}
